class Message < ActiveRecord::Base
  belongs_to :project
  belongs_to :author, :class_name => "User", :foreign_key => "author_id"
  belongs_to :milestone
  
  has_many :comments, :as => :commentable
  
  has_many :logs, :as => :loggable
  
  after_create :log_creation
  
  def log_creation
    logs.new(:project => project, :action => "posted", :user_id => Thread.current[:user_id]).save
  end
end